﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WEALTH
{
    public partial class MoneyManageOrder : ClientBasePage
    {
        ExcuteDao dao = new ExcuteDao();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string cname = string.Empty;
                string csex = string.Empty;
                string ctel = string.Empty;
                string cphone = string.Empty;
                string cemail = string.Empty;
                string caddress = string.Empty;
                string czipcode = string.Empty;
                string cage = string.Empty;
                string cguoqutouzi = string.Empty;
                string cliaojielicai = string.Empty;
                string cxuqiu = string.Empty;

                cname = SpecialCharHandler.HtmlEncode(username.Text);
                if (radbtnSex0.Checked)
                { csex = radbtnSex0.Text; }
                else if (radbtnSex1.Checked)
                { csex = radbtnSex1.Text; }
                ctel = SpecialCharHandler.HtmlEncode(phone.Text);
                cphone = SpecialCharHandler.HtmlEncode(mobilphone.Text);
                cemail = SpecialCharHandler.HtmlEncode(email.Text);
                caddress = SpecialCharHandler.HtmlEncode(address.Text);
                czipcode = SpecialCharHandler.HtmlEncode(zipcode.Text);

                if (radio1.Checked)
                {
                    cage = radio1.Text;
                }
                if (radio2.Checked)
                {
                    cage = radio2.Text;
                }
                if (radio3.Checked)
                {
                    cage = radio3.Text;
                }
                if (radio4.Checked)
                {
                    cage = radio4.Text;
                }
                if (radio21.Checked)
                {
                    cguoqutouzi = radio21.Text;
                }
                if (radio22.Checked)
                {
                    cguoqutouzi = radio22.Text;
                }
                if (radio23.Checked)
                {
                    cguoqutouzi = radio23.Text;
                }
                if (radio24.Checked)
                {
                    cguoqutouzi = radio24.Text;
                }
                if (checkbox1.Checked)
                {
                    cliaojielicai += checkbox1.Text + ",";
                }
                if (checkbox2.Checked)
                {
                    cliaojielicai += checkbox2.Text + ",";
                }
                if (checkbox3.Checked)
                {
                    cliaojielicai += checkbox3.Text + ",";
                }
                if (checkbox4.Checked)
                {
                    cliaojielicai += checkbox4.Text + ",";
                }
                cliaojielicai = cliaojielicai.TrimEnd(',');

                cxuqiu = SpecialCharHandler.HtmlEncode(txtcontent.Value);

                //添加用户信息到数据库中
                if (dao.Insert_yuyue(cname, csex, ctel, cphone, cemail,
                    caddress, czipcode, cage, cguoqutouzi, cliaojielicai, cxuqiu) == 1)
                {
                    ShowMsg("预约成功！", 0);
                    clearText();
                }
                else
                {
                    ShowMsg("预约失败,请重新预约或联系客服！", 1);
                }
            }
            catch (Exception ex)
            {
                AppFunction.SaveExceptionLog(ex);
                ShowMsg("预约失败,请重新预约或联系客服！", 0);
            }
        }
        private void clearText()
        {
            username.Text = string.Empty;
            radbtnSex0.Checked = false;
            radbtnSex1.Checked = false;
            phone.Text = string.Empty;
            mobilphone.Text = string.Empty;
            email.Text = string.Empty;
            address.Text = string.Empty;
            zipcode.Text = string.Empty;
            radio1.Checked = false;
            radio2.Checked = false;
            radio3.Checked = false;
            radio4.Checked = false;
            radio21.Checked = false;
            radio22.Checked = false;
            radio23.Checked = false;
            radio24.Checked = false;
            checkbox1.Checked = false;
            checkbox2.Checked = false;
            checkbox3.Checked = false;
            checkbox4.Checked = false;
            txtcontent.Value = string.Empty;
        }
    }
}